﻿@using OBUCare.Web.Infrastructure
@using OBUCare.Core.BL
@using OBUCare.Core.DataAccess;
@{
    ObuDropDownListHlper ddlHelper = new ObuDropDownListHlper();     
}
@using (Html.BeginForm("repairDailySearch", "Report", FormMethod.Post, new { @id = "searchForm" }))
{

    <table width="100%">
        <tr>
            <td style="width: 20%; text-align: right">
                开始日期：
            </td>
            <td style="width: 30%; text-align: left">
                @Html.Telerik().DatePicker().Name("FromCreatedDate").HtmlAttributes(new { @style = "width:170px;" }).OpenOnFocus(true).ShowButton(false)
            </td>
            <td style="width: 20%; text-align: right">
                结束日期：
            </td>
            <td style="width: 30%; text-align: left">
                @Html.Telerik().DatePicker().Name("ToCreatedDate").HtmlAttributes(new { @style = "width:170px;" }).OpenOnFocus(true).ShowButton(false)
            </td>
        </tr>
        <tr>
            <td style="text-align: right">
                营业厅：
            </td>
            <td style="text-align: left">
                @Html.Telerik().DropDownList().Name("Agent").HtmlAttributes(new { @style = "Width:160px;" }).BindTo(ddlHelper.GetAgents(UIConstants.AllItems, true, "", "", new KeyValuePair<string, string>(UIConstants.AllItems, UIConstants.AllItems)))
            </td>
            <td style="text-align: right;">
                操作员：
            </td>
            <td style="text-align: left">
                @Html.Telerik().DropDownList().Name("Operator").BindTo(ddlHelper.GetOperators(UIConstants.AllItems, true, new KeyValuePair<string, string>(UIConstants.AllItems, UIConstants.AllItems)))
            </td>
        </tr>
        <tr>
            <td colspan="2">
            </td>
            <td colspan="2" style="text-align: center">
                <input type="button" value="查询" id="btnSearch" onclick="search()" />
                @Html.Hidden("searchSql", "", new { @id = "searchSql" })
            </td>
        </tr>
    </table>
    
    
}
<script type="text/javascript">

    function search() {
        if ($.trim($('#FromCreatedDate').val()) == "" || $.trim($('#ToCreatedDate').val()) == "") {
            alert("请输入完整日期");
            return false;
        }
        var form = $("#searchForm");
        dataString = form.serialize();
        $.ajax({
            type: "POST",
            url: form.attr('action'),
            data: dataString,
            cache: false,
            dataType: "json",
            success: function (data) {

                if (data.Success) {
                    //alert('成功');
                    //debugger;
                    var grid = $('#Grid').data('tGrid')
                    $('#searchSql').val(data.SearchSql)
                    grid.rebind();
                    $('#spanOneRepair').html(data.OneRepair);
                    $('#spanReturnDeposit').html(data.ReturnDeposit);
                    $('#spanCollectsDeposit').html(data.CollectsDeposit);
                    $('#spanRepairObu').html(data.RepairObu);
                    $('#spanIssueSpareTape').html(data.IssueSpareTape);
                    $('#spanIssueBase').html(data.IssueBase);
                    $('#spanRepairServiceFee').html(data.RepairServiceFee);
                    $('#spanSUM_PRICE').html(data.SUM_PRICE);
                }
                else {
                    alert('失败：' + data.ErrorMsg)
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var err = XMLHttpRequest + "<br />" + textStatus + "<br />" + errorThrown;
                alert(err);
            }
        });
    }

</script>
@{
    ddlHelper.Dispose();    
}
